<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>立即登记新会员</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css">
<!--公共样式结束-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/module_form.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/page_memberAdd.css">
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<script src="__PUBLIC__/Plugins/Datepicker/WdatePicker.js"></script>
<style>
.orderno{
	color:#FFF;
	cursor:pointer;
	padding:3px 6px;
	background-color:#339900;
}
.ele_content{
	width:300px;
}
.deladdress{
	color:#FFF;
	cursor:pointer;
	padding:3px 6px;
	background-color:#339900;
}
</style>
</head>

<body>
 	<div class="page_header">
		<div class="tabbar">
			<ul class="tab clearfix" tabname="tab1">
				<li class="tabhover" show="tab1_0">基本信息</li>
				<li show="tab1_1">订单信息</li>
				<li show="tab1_2">地址信息</li>
			</ul>
		</div>
	</div> 
	<div class="page_wraper">
		<div id="tab1_0" fortab="tab1">
			<form id="memberAdd_form">
			<input type="hidden" id="solevar" name="solevar" value="{:create_id()}">
			<input type="hidden" id="id"      name="id"      value="{$detail.id}">
			
			<table cellpadding="0" cellspacing="0" class="module_form" width="600">
				<tr>
					<td class="ele_title"><label for="username">姓名：</label></td>
					<td class="ele_content">{$detail.realname}</td>
					<td class="ele_title"><label for="sex">性别：</label></td>
					<td class="ele_content"><eq name="detail.sex" value="1">先生<else />女士</eq></td>
				</tr>
				<tr>
					<td class="ele_title"><label for="phone">手机号码1：</label></td>
					<td class="ele_content">{$detail.mobile}</td>
					<td class="ele_title"><label for="phone">手机号码2：</label></td>
					<td class="ele_content">{$detail.phone}</td>
					
					
				</tr>
				<tr>
					<td class="ele_title"><label for="email">电子邮件：</label></td>
					<td class="ele_content">{$detail.email}</td>
					<td class="ele_title"><label for="email">电子邮件2：</label></td>
					<td class="ele_content">{$detail.email2}</td>
				</tr>
				<!-- <tr>
					<td class="ele_title"><label for="address1">所在省：</label></td>
					<td colspan="3" class="ele_content">
						<div id="areaBox"></div>
						<input type="text" name="enssxadd" id="enssxadd" class="form_ele_text width_400" readonly />
					</td>
				</tr> 
				<tr>
					<td class="ele_title"><label for="enaddress">详细地址：</label></td>
					<td colspan="3" class="ele_content">{$detail.address}</td>
				</tr>-->
				<tr>
					<td class="ele_title"><label for="enaddress">会员备注：</label></td>
					<td colspan="3" class="ele_content">{$detail.remark}</td>
				</tr>
				<tr>
					<td class="ele_title"><label for="enaddress">客服备注：</label></td>
					<td colspan="3" class="ele_content">{$detail.remark1}</td>
				</tr>
				<tr>
					<td colspan="4" style="height:30px;"></td>
				</tr>
			</table>
			</form>
		</div>
 	
		<div id="tab1_1" fortab="tab1" class="clearfix" style="display:none;">
			<table cellpadding="0" cellspacing="0" class="module_form" width="600">
				<tr>
					<td class="ele_title">订单编号</td>
					<td class="ele_title">订单状态</td>
					<td class="ele_title">服务金额</td>
					<td class="ele_title">优惠金额</td>
					<td class="ele_title">实付金额</td>
					<td class="ele_title">下单时间</td>
					<td class="ele_title">&nbsp;</td>
				</tr>
				<volist name="list" id="v" empty="$empty">
					<tr>
						<td class="">{$v.orderno}</td>
						<td class="">{$v.status|get_array_key='ORDER_STATUS',###}</td>
						<td class="">￥{$v.shipfee}</td>
						<td class="">￥{$v.cardfee}</td>
						<td class="">￥{$v.orderfee}</td>
						<td class="">{$v.addtime|date="Y-m-d H:i",###}</td>
					<td class="">
						<a class="openwin orderno" etitle="订单详情" eheight="500px" ewidth="1000px" ehref="{:U('Order/printOrder')}&id={$v.id}" id="Order_printOrder">
						查看</a></td>
					</tr>
				</volist>
			</table>
		</div>
		<div id="tab1_2" fortab="tab1" class="clearfix" style="display:none;">
			<table cellpadding="0" cellspacing="0" class="module_form" width="600">
				<tr>
					<td class="ele_title" width="10%">收件人</td>
					<td class="ele_title" width="15%">电话</td>
					<td class="ele_title" width="52%">地址</td>
					<td class="ele_title" width="15%">添加时间</td>
					<td class="ele_title" width="8%">操作</td>
				</tr>
				<volist name="address" id="v" empty="$empty1">
					<tr>
						<td class="">{$v.realname}</td>
						<td class="">{$v.mobile}</td>
						<td class="">{$v.address}</td>
						<td class="">{$v.addtime|date="Y-m-d H:i",###}</td>
						<td><span class="deladdress" id="{$v.id}" userid="{$detail.id}">删除</span></td>
					</tr>
				</volist>
			</table>
		</div> 

	</div>
	<div class="page_footer pdtd10">
		<!-- <input type="button" name="submit" value="提交数据"  class="form_ele_submit"/>
		<input type="reset" name="reset" value="清空数据"  class="form_ele_reset"/> -->
	</div>
</body>
<script type="text/javascript">
	//弹出窗口全局变量
	var api = frameElement.api, W = api.opener;

	$(function(){
		//滑动门
		$('.tabbar li').click(function(){
			var tabname = $('.tabbar>ul').attr('tabname');
			$('.tabbar li').removeClass('tabhover');
			$(this).addClass('tabhover');
			
			$('div[fortab="'+tabname+'"]').hide();
			$('#'+$(this).attr('show')).show();
		});
		
		//表格隔行换色
		$('.module_form tr:odd').addClass('odd');
		$('.module_form tr:even').addClass('even');
		
		//表单操作
		//重置
		$('.form_ele_reset').on('click',function(){
			$('#memberAdd_form').get(0).reset();
		});
		
		$('#slef').change(function(){
			$("#vipno").val('');
			$("#vipno").attr("readonly",false);
		});

		//删除地址
		$('.deladdress').live('click',function(){
			var id   = $(this).attr('id');
			var user = $(this).attr('userid');
			var msg  = "确认要删除该地址吗？";
			var obj  = $(this);

			windowApi.lhgdialog.confirm(msg, function(){
				$.post("{:U('Custom/deladdress')}",{id:id,user:user},function(data){
					if(data.status==1){
						obj.parents('tr').remove();
					}else{
						windowApi.lhgdialog.alert(data.info,function(){return;});
					}
				});
			},function(){
				return;
			});
		});
		
		$('#cardid').change(function(){
			if($("#slef").attr("checked")){
				var cardid = $("#cardid").val();
				
				if(cardid){
					$.post("{:U('Vipcard/getVipno')}",{'cardid':cardid},function(data){    //发异步请求会员卡号
						$("#vipno").val(data);
						$("#vipno").attr("readonly","readonly");
					});
				}
			}
		})
		
		//提交
		$('.form_ele_submit').on('click',function(){
			
			var tipsObj = windowApi.lhgdialog.tips('正在提交数据...',10,etIcon.loading);
			var postData = {};
			postData = $("#memberAdd_form").serialize();
			
			$.post("{:U('Custom/edit')}", postData ,function(data){
				windowApi.lhgdialog.tips('数据提交成功！',1,etIcon.success,function(){
					
					frameApi.close(); //关闭当前窗口
					var obj = windowApi.lhgdialog.list['Custom_index'];
					obj.reload(obj);
				});
			},"json");
		});
	});
	
	//省市县三级联动
	var linkage_json   = {$dictAddressCN|json_encode} ;
	var linkage_jsonen = {$dictAddressEN|json_encode};
	$(function(){
		//初始值处理
		var did = '';
		if(did!=''){
			$('#areaBox').html(dealInitialarea(did,'',1));
		}else{
			$('#areaBox').html(showLinkagearea(39,2,0));
		}
		$('select[name="area"]').live('change',function(){
			var nowLevel  = parseInt($(this).attr('level'));
			var nextLevel = nowLevel+1;
			var enhtml    = '';
			
			//清除自此以后的select
			$('select[name="area"]').each(function(index, element) {
				if(parseInt($(this).attr('level'))>nowLevel){
					$(this).remove();
				}
			});
			//给英文城市地址赋值
			$('select[name="area"]').each(function(index, element) {				
				var areaid = $(this).val();
				if(linkage_jsonen[areaid]){
					enhtml += linkage_jsonen[areaid][0];
				}
			});
			
			$('#ssxadd').val($('select[name="area"]').find("option:selected").text());
			$('#enssxadd').val(enhtml);
			
			$('input[name="area'+nowLevel+'"]').val($(this).val());
			//显示下一个select
			$('#areaBox').append(showLinkagearea($(this).val(),nextLevel,0));
		});
		
		//处理初始值
		function dealInitialarea(lid,result,level){
			if(lid){
				$.each(linkage_json , function(i, n){
					if(lid==i){
						result = dealInitialarea(n[1],result,(parseInt(level)-1))+''+showLinkagearea(n[1],level,i);
						return false;
					}
				});
			}
			return result;
		}
		
		//响应select改变事件
		function showLinkagearea(pid,level,nid){
			var html = ''; //最终输出的HTML
			var have = false; //是否有子词典
			html += '<select name="area" id="area'+level+'" level="'+level+'">';
			html += '<option value="0">请选择</option>';
			$.each(linkage_json , function(i, n){
				if(pid==n[1]){
					if(nid==i){
						html += '<option value="'+i+'" selected>'+n[0]+'</option>';
					}else{
						html += '<option value="'+i+'">'+n[0]+'</option>';
					}
					have = true;
				}
			});
			html += '</select>';
			html += '<input type="hidden" name="area'+level+'"/>';
			
			//没有子词典则此次输出为空
			if(!have){
				html = '';
			}
			return html;
		}
	});
</script>
</html>
